package com.ruoyi.jiajia.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.JiajiaTransferAccounts;
import com.ruoyi.system.domain.vo.JiajiaTransferAccountsVo;
import com.ruoyi.system.service.IJiajiaTransferAccountsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 微信打款Controller
 * 
 * @author ruoyi
 * @date 2025-04-25
 */
@Controller
@RequestMapping("/system/accounts")
public class JiajiaTransferAccountsController extends BaseController
{
    private String prefix = "system/accounts";

    @Autowired
    private IJiajiaTransferAccountsService jiajiaTransferAccountsService;

    @RequiresPermissions("system:accounts:view")
    @GetMapping()
    public String accounts()
    {
        return prefix + "/accounts";
    }

    /**
     * 查询微信打款列表
     */
    @RequiresPermissions("system:accounts:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaTransferAccounts jiajiaTransferAccounts)
    {
        startPage();
        List<JiajiaTransferAccountsVo> list = jiajiaTransferAccountsService.selectJiajiaTransferAccountsList(jiajiaTransferAccounts);
        return getDataTable(list);
    }

    /**
     * 导出微信打款列表
     */
    @RequiresPermissions("system:accounts:export")
    @Log(title = "微信打款", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaTransferAccounts jiajiaTransferAccounts)
    {
        List<JiajiaTransferAccountsVo> list = jiajiaTransferAccountsService.selectJiajiaTransferAccountsList(jiajiaTransferAccounts);
        ExcelUtil<JiajiaTransferAccountsVo> util = new ExcelUtil<JiajiaTransferAccountsVo>(JiajiaTransferAccountsVo.class);
        return util.exportExcel(list, "微信打款数据");
    }

    /**
     * 新增微信打款
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存微信打款
     */
    @RequiresPermissions("system:accounts:add")
    @Log(title = "微信打款", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaTransferAccounts jiajiaTransferAccounts)
    {
        return toAjax(jiajiaTransferAccountsService.insertJiajiaTransferAccounts(jiajiaTransferAccounts));
    }

    /**
     * 修改微信打款
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaTransferAccounts jiajiaTransferAccounts = jiajiaTransferAccountsService.selectJiajiaTransferAccountsById(id);
        mmap.put("jiajiaTransferAccounts", jiajiaTransferAccounts);
        return prefix + "/edit";
    }

    /**
     * 修改保存微信打款
     */
    @RequiresPermissions("system:accounts:edit")
    @Log(title = "微信打款", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaTransferAccounts jiajiaTransferAccounts)
    {
        return toAjax(jiajiaTransferAccountsService.updateJiajiaTransferAccounts(jiajiaTransferAccounts));
    }

    /**
     * 删除微信打款
     */
    @RequiresPermissions("system:accounts:remove")
    @Log(title = "微信打款", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaTransferAccountsService.deleteJiajiaTransferAccountsByIds(ids));
    }
}
